<?php

namespace App\Admin\Actions\UserAction;

use Encore\Admin\Actions\RowAction;
use Illuminate\Database\Eloquent\Model;

class CertificationBindDismiss extends RowAction
{
    public $name = '实名认证解绑';
    
    public function handle(Model $model)
    {
    	if (!$model->identify_num) {
    		return $this->response()->error('未实名认证');
	    }
    	
    	$model->update([
    		'identify_num'=>null,
    		'auth_real_name'=>null
    	]);
    	
	    return $this->response()->success('实名认证解绑成功')->refresh();
    }
	
	public function dialog()
	{
		$this->confirm('确定解除当前用户的实名认证绑定?');
	}
}
